// index 页面方法

function isScrollBottom() {
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
    var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
    if (scrollTop + windowHeight >= scrollHeight) {
        return true;    // 到底部
    }
    else {
        return false;
    }
};


function throttle(func, wait, mustRun) {
    var timeout, startTime = new Date();

    return () => {
        curTime = new Date();

        clearTimeout(timeout);

        if (curTime - startTime >= mustRun) {
            // 必须触发一次
            func.apply();
            startTime = curTime;    // 初始化
        }
        else {
            timeout = setTimeout(func, wait)
        };
    };
};


function refresh() {
    if (isScrollBottom()) {
        // console.log('success')
        // 滚动条到底刷新事件
    }
}

window.addEventListener('scroll', throttle(refresh, 250, 1000));